home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / test / pack.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-07  |  3.6 KB  |  119 lines

  1. //
  2. // "$Id: pack.cxx,v 1.4 1999/01/07 19:17:59 mike Exp $"
  3. //
  4. // Fl_Pack test program for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Rather crude test of the Fl_Pack object.
  7. // Changing the type() of an Fl_Pack after it is displayed is not supported
  8. // so I have to do a lot of resizing of things before that.
  9. //
  10. // Copyright 1998-1999 by Bill Spitzak and others.
  11. //
  12. // This library is free software; you can redistribute it and/or
  13. // modify it under the terms of the GNU Library General Public
  14. // License as published by the Free Software Foundation; either
  15. // version 2 of the License, or (at your option) any later version.
  16. //
  17. // This library is distributed in the hope that it will be useful,
  18. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  20. // Library General Public License for more details.
  21. //
  22. // You should have received a copy of the GNU Library General Public
  23. // License along with this library; if not, write to the Free Software
  24. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  25. // USA.
  26. //
  27. // Please report all bugs and problems to "fltk-bugs@easysw.com".
  28. //
  29.  
  30. #include <FL/Fl.H>
  31. #include <FL/Fl_Button.H>
  32. #include <FL/Fl_Light_Button.H>
  33. #include <FL/Fl_Window.H>
  34. #include <FL/Fl_Scroll.H>
  35. #include <FL/Fl_Value_Slider.H>
  36. #include <FL/Fl_Pack.H>
  37.  
  38. Fl_Pack *pack;
  39. Fl_Scroll *scroll;
  40.  
  41. void type_cb(Fl_Light_Button*, long v) {
  42.   for (int i = 0; i < pack->children(); i++) {
  43.     Fl_Widget* o = pack->child(i);
  44.     o->resize(0,0,25,25);
  45.   }
  46.   pack->resize(scroll->x(),scroll->y(),scroll->w(),scroll->h());
  47.   pack->parent()->redraw();
  48.   pack->type(uchar(v));
  49.   pack->redraw();
  50. }
  51.  
  52. void spacing_cb(Fl_Value_Slider*o, long) {
  53.   pack->spacing(int(o->value()));
  54.   scroll->redraw();
  55. }
  56.  
  57. int main(int argc, char **argv) {
  58.  Fl_Window *w;
  59.  {Fl_Window* o = new Fl_Window(365, 525);
  60.   w = o;
  61.   scroll = new Fl_Scroll(10,10,345,285);
  62.  {Fl_Pack* o = new Fl_Pack(10, 10, 345, 285);
  63.   pack = o;
  64.   o->box(FL_DOWN_FRAME);
  65.   //o->box(FL_ENGRAVED_FRAME);
  66.  new Fl_Button(35, 35, 25, 25, "b1");
  67.  new Fl_Button(45, 45, 25, 25, "b2");
  68.  new Fl_Button(55, 55, 25, 25, "b3");
  69.  new Fl_Button(65, 65, 25, 25, "b4");
  70.  new Fl_Button(75, 75, 25, 25, "b5");
  71.  new Fl_Button(85, 85, 25, 25, "b6");
  72.  new Fl_Button(95, 95, 25, 25, "b7");
  73.  new Fl_Button(105, 105, 25, 25, "b8");
  74.  new Fl_Button(115, 115, 25, 25, "b9");
  75.  new Fl_Button(125, 125, 25, 25, "b10");
  76.  new Fl_Button(135, 135, 25, 25, "b11");
  77.  new Fl_Button(145, 145, 25, 25, "b12");
  78.  new Fl_Button(155, 155, 25, 25, "b13");
  79.  new Fl_Button(165, 165, 25, 25, "b14");
  80.  new Fl_Button(175, 175, 25, 25, "b15");
  81.  new Fl_Button(185, 185, 25, 25, "b16");
  82.  new Fl_Button(195, 195, 25, 25, "b17");
  83.  new Fl_Button(205, 205, 25, 25, "b18");
  84.  new Fl_Button(215, 215, 25, 25, "b19");
  85.  new Fl_Button(225, 225, 25, 25, "b20");
  86.  new Fl_Button(235, 235, 25, 25, "b21");
  87.  new Fl_Button(245, 245, 25, 25, "b22");
  88.  new Fl_Button(255, 255, 25, 25, "b23");
  89.  new Fl_Button(265, 265, 25, 25, "b24");
  90.   o->end();
  91.   w->resizable(o);
  92.  }
  93.  scroll->end();
  94.  {Fl_Light_Button* o = new Fl_Light_Button(10, 325, 175, 25, "HORIZONTAL");
  95.  o->type(FL_RADIO_BUTTON);
  96.   o->callback((Fl_Callback*)type_cb, (void*)(Fl_Pack::HORIZONTAL));
  97.  }
  98.  {Fl_Light_Button* o = new Fl_Light_Button(10, 350, 175, 25, "VERTICAL");
  99.  o->type(FL_RADIO_BUTTON);
  100.  o->value(1);
  101.   o->callback((Fl_Callback*)type_cb, (void*)(Fl_Pack::VERTICAL));
  102.  }
  103.  {Fl_Value_Slider* o = new Fl_Value_Slider(50,375, 295,25,"spacing:");
  104.  o->align(FL_ALIGN_LEFT);
  105.  o->type(FL_HORIZONTAL);
  106.  o->range(0,30);
  107.  o->step(1);
  108.  o->callback((Fl_Callback*)spacing_cb);
  109.  }
  110.  w->end();
  111.  }
  112.  w->show(argc, argv);
  113.  return Fl::run();
  114. }
  115.  
  116. //
  117. // End of "$Id: pack.cxx,v 1.4 1999/01/07 19:17:59 mike Exp $".
  118. //
  119.